<template>
  <div>
      <h2>添加投资</h2>
      <table class="table table-bordered">
        <tr>
          <td>投资名称</td>
          <td>
            <input type="text" v-model="info.tname">
          </td>
        </tr>
        <tr>
          <td>投资总额度</td>
          <td>
            <input type="text" v-model="info.pricecount">
          </td>
        </tr>
        <tr>
          <td colspan="2" style="text-align: center;">
            <input type="button" value="添加" @click="Add">
          </td>

        </tr>
      </table>
  </div>
</template>

<script setup lang="ts">
import{ref} from 'vue'
import axios from 'axios'
import{useRouter} from 'vue-router' 
let  router=useRouter();

const info=ref({
  tname:'',
  pricecount:"",
  de:true
})


const Add=()=>{
  if(info.value.tname==""||info.value.pricecount=="")
  {
    alert("请输入投资名称和投资总额度");
    return;
  }
  axios({
    url:"http://localhost:50462/api/CF/Add",
    method:"post",
    data:info.value
  }).then((res)=>{
    if(res.data==3)
    {
      alert("投资名称已存在");
      return;

    }
    else if(res.data>0)
    {
      alert("添加成功");
      router.push("/ShowView");

    }
    else
    {
      alert("添加失败");
    }


})
}
</script>

<style scoped>

</style>